﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace BomberManServer.Utils
{
    public class Constants
    {
        public static Constants instance {get; private set;}
        
        public UInt32 speed { get; private set; }
        public UInt32 deflag_length { get; private set; }
        public UInt32 bomb_delay { get; private set; }
        public UInt32 bomb_max { get; private set; }
        public UInt32 bomb_expire { get; private set; }
        public UInt32 avatarSize { get; private set; }
        
        public UInt32 pointsPerBlock { get; private set; }
        public UInt32 theoricPointsPerBlock { get; private set; }
        
        public BomberManServer.Gaming.Object.Mapping.Model.States.Rock stateRock { get; private set; }
        public BomberManServer.Gaming.Object.Mapping.Model.States.Free stateFree { get; private set; }
        
        public int maxThreadPool { get; private set; }
        public int maxTimerBomb { get; private set; }
        
        public int actions_per_second { get; private set; }
        
        public int baseSocket { get; private set; }
        
        public uint deflagStandstill { get; private set; }

        // Bonus
        public UInt32 tempPower { get; private set; }
        public UInt32 permPower { get; private set; }
        public int tempDuration { get; private set; }
        public int tempRepop { get; private set; }
        public UInt32 speedCoef { get; private set; }
        public float delayCoef { get; private set; }
        public int onlyTempType { get; private set; }

        public UInt32 maxFFARound { get; private set; }
        public UInt32 requiredTeamWin { get; private set; }
        public UInt32 requiredFFAKill { get; private set; }
        public int timerRound { get; private set; }
        public int timerScoreBoard { get; private set; }
        public int timerSlabReset { get; private set; }
        public int secondsBeforeInactiv { get; private set; }
        public UInt32 pointsGlide { get; private set; }

        public int densityMin { get; private set; }
        public int densityMax { get; private set; }

        public UInt16 nbBonusDuel { get; private set; }
        public UInt16 nbBonusMelee { get; private set; }

        public int bomb_Modifier { get; private set; }

        public static void initialize()
        {
            instance = new Constants();
        }
        private Constants()
        {
            
            // Avatar
            this.speed = UInt32.Parse(ConfigurationManager.AppSettings["speed"]);
            this.deflag_length = UInt32.Parse(ConfigurationManager.AppSettings["deflag_length"]);
            this.bomb_delay = UInt32.Parse(ConfigurationManager.AppSettings["bomb_delay"]);
            this.bomb_max = UInt32.Parse(ConfigurationManager.AppSettings["bomb_max"]);
            this.bomb_expire = UInt32.Parse(ConfigurationManager.AppSettings["bomb_expire"]);
            this.avatarSize = UInt32.Parse(ConfigurationManager.AppSettings["avatarSize"]);

            // Coordinates
            this.pointsPerBlock = UInt32.Parse(ConfigurationManager.AppSettings["pointsPerBlock"]);
            this.theoricPointsPerBlock = UInt32.Parse(ConfigurationManager.AppSettings["theoricPointsPerBlock"]);

            // States
            this.stateRock = new BomberManServer.Gaming.Object.Mapping.Model.States.Rock();
            this.stateFree = new BomberManServer.Gaming.Object.Mapping.Model.States.Free();
            
            //Map Item
            BomberManServer.Gaming.Object.Mapping.Items.None.create();
            BomberManServer.Gaming.Object.Mapping.Items.Rock.create();

            // Socket _ thread
            this.baseSocket = int.Parse(ConfigurationManager.AppSettings["baseSocket"]);
            this.maxThreadPool = int.Parse(ConfigurationManager.AppSettings["maxThreadPool"]);


            this.maxTimerBomb = int.Parse(ConfigurationManager.AppSettings["maxTimerBomb"]);

            //Scheduler
            this.actions_per_second = int.Parse(ConfigurationManager.AppSettings["actions_per_second"]);
            this.deflagStandstill = uint.Parse(ConfigurationManager.AppSettings["deflagStandstill"]);

            //BOnus
            this.tempDuration = int.Parse(ConfigurationManager.AppSettings["tempDuration"]);
            this.tempPower = UInt32.Parse(ConfigurationManager.AppSettings["tempPower"]);
            this.tempRepop = int.Parse(ConfigurationManager.AppSettings["tempRepop"]);
            this.speedCoef = UInt32.Parse(ConfigurationManager.AppSettings["speedCoef"]);
            this.delayCoef = float.Parse(ConfigurationManager.AppSettings["delayCoef"]);
            this.permPower = UInt32.Parse(ConfigurationManager.AppSettings["permPower"]);
            this.onlyTempType = int.Parse(ConfigurationManager.AppSettings["onlyTempType"]);

            this.maxFFARound = UInt32.Parse(ConfigurationManager.AppSettings["maxFFARound"]);
            this.requiredTeamWin = UInt32.Parse(ConfigurationManager.AppSettings["requiredTeamWin"]);
            this.requiredFFAKill = UInt32.Parse(ConfigurationManager.AppSettings["requiredFFAKill"]);
            this.timerRound = int.Parse(ConfigurationManager.AppSettings["timerRound"]);
            this.timerScoreBoard = int.Parse(ConfigurationManager.AppSettings["timerScoreBoard"]);
            this.secondsBeforeInactiv = int.Parse(ConfigurationManager.AppSettings["secondsBeforeInactiv"]);

            this.pointsGlide = UInt32.Parse(ConfigurationManager.AppSettings["pointsGlide"]);

            this.densityMin = int.Parse(ConfigurationManager.AppSettings["densityMin"]);
            this.densityMax = int.Parse(ConfigurationManager.AppSettings["densityMax"]);
            this.nbBonusDuel = UInt16.Parse(ConfigurationManager.AppSettings["nbBonusDuel"]);
            this.nbBonusMelee = UInt16.Parse(ConfigurationManager.AppSettings["nbBonusMelee"]);

            this.bomb_Modifier = int.Parse(ConfigurationManager.AppSettings["bomb_Modifier"]);
            this.timerSlabReset = int.Parse(ConfigurationManager.AppSettings["slabReset"]);


        }
    }
}
